/*
 * @Date: 2021-09-12 19:21:05
 * @Author: Acckno1
 * @LastEditTime: 2021-09-12 19:21:54
 * @Description: 
 */
#include <iostream>
#include <cstring> 
#include <algorithm>
#include <queue>

using namespace std;

const int N = 110;

int e[N], ne[N], h[N], idx;
int n, m;
bool st[N];
int cnt[N];

// a->b
void add(int a, int b) {
    e[idx] = b, ne[idx] = h[a], h[a] = idx ++;
}

int main() {
    memset(h, -1, sizeof h);
    cin >> n >> m;
    
    for (int i = 0; i < m; i ++ ) {
        int id, k;
        cin >> id >> k;
        while (k -- ) {
            int son;
            cin >> son;
            add(id, son);
        }
    }
    
    queue<int> q;
    q.push(1);
    st[1] = true;
    int depth = 0;
    cnt[depth] = 0;
    
    // 判断是否只有一个根
    if (h[1] == -1) {
        cnt[depth] = 1;
        q.pop();
    }
    
    while (q.size()) {
        int s = q.size();
        int c = 0;
        // 循环每一层
        for (int _ = 1; _ <= s; _ ++ ) {
            int t = q.front();q.pop();
            for (int i = h[t]; i != -1; i = ne[i]) {
                int j = e[i];
                if (h[j] == -1) {c ++; continue;}
                if (!st[j]) {
                    st[j] = true;
                    q.push(j);
                }
            }
        }
        // 统计non-leaf node
        cnt[++ depth] = c;
    }
    
    cout << cnt[0];
    for (int i = 1; i <= depth; i ++ ) {
        cout  << " " << cnt[i];
    }
    return 0;
}